home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Internet Tools (InfoMagic)
/
Internet Tools.iso
/
news
/
moderating
/
ckngrps.shar.Z
/
ckngrps.shar
/
ckngrps
Wrap
Text File
|
1993-11-22
|
3KB
|
133 lines
#!/bin/sh
#
# File Name: ckngrps.sh
# Purpose : Determine if a Newsgroups: line contains entries for
# other moderated groups if crossposting.
# Usage : Edit the specific declarations below.
#
# from-within-mailer | ckngrps.sh
#
# This script was written in about 30 minutes. Please be kind...
# It uses the article command from the rkive package. If anyone
# needs a copy, let me know and I'll send it. You should be able
# to easily hack it to use grep but article commands were quicker
# for me to write... ;-) Quickly tested on a Sun SparcStation.
#
# Kent Landfield
# kent@sparky.sterling.com
#
###################################################################
#
# CHANGE THESE FOR YOUR SPECIFIC NEWSGROUP NEEDS
#
#set -x
ME=kent@sparky.sterling.com
MYGROUP=comp.sources.misc
# Location Variable declarations
ACTIVE=/usr/lib/news/active
ARTICLE=/usr/local/bin/article
TMPDIR=/usr/tmp
# Temp file
TMPFILE=${TMPDIR}/ckngrps.$$
cat - > ${TMPFILE}
# cleanup
trap "rm -f ${TMPFILE}; exit 0" 0 1 2 15
#
# Get the Newsgroups line from the article and
# replace and ','s with blank spaces.
#
set `${ARTICLE} -f "%N" ${TMPFILE} | sed "s/,/ /g"`
#
# While we have newsgroups specified...
#
num=0
numbad=0
while [ "$1" != "" ]
do
num=`expr ${num} + 1`
#
# if its my group then I know about it so skip past it.
#
if [ "$1" != ${MYGROUP} ]
then
#
# Need to determine if the other group is moderated.
# Deal with multiple groups with the same partial name.
# I'm sure that there is a better way but this was cheap
# and sleezy.
#
mflag=`grep "^$1" ${ACTIVE} | awk '{
if ($1 == NG) {
print $4
break
}
else {
printf "-"
continue
}
}' NG=$1 `
#
# if no match then skip the rest.
#
if [ "${mflag}" = "-" ]
then
continue
#
# Is it moderated ?
#
elif [ "${mflag}" = "m" ]
then
echo "WARNING: $1 is a moderated group! "
echo " EDIT: $1 out of Newsgroups: line before posting!"
numbad=`expr ${numbad} + 1`
fi
fi
shift
done
#
# Everybody likes totals... :-)
#
echo "====="
case ${num} in
0) echo "No Newsgroups Line encountered"
;;
1) if [ ${numbad} -eq 1 ]; then
echo "Is this a posting for ${MYGROUP} ???"
fi
;;
*) echo -n "Crossposting to ${num} groups, "
#
# Correct usage of the English language never hurts...
#
if [ ${numbad} -eq 1 ]; then
echo "${numbad} is moderated and should be corrected."
else
echo "${numbad} are moderated and should be corrected."
fi
;;
esac
#
# We're history.
#
echo
echo -n "Press Return to continue:-> "
read ans < /dev/tty
exit 0